package com.tscnd.core.service.resource.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tscnd.core.dao.resource.IResourceDao;
import com.tscnd.core.entity.resource.Resource;
import com.tscnd.core.exception.TSException;
import com.tscnd.core.service.resource.IResourceService;

@Service("resourceService")
public class ResourceServiceImpl implements IResourceService {
	@Autowired
	public IResourceDao resourceDao;

	@Override
	public List<Resource> getAll() throws TSException
	{
		try
		{
			return resourceDao.getAll();
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new TSException("查询所有资源信息失败\r\n" + e.getMessage());
		}
	}

	@Override
	public List<Resource> findByRole(String roleId) throws TSException
	{
		try
		{
			return resourceDao.findRoleByResource(roleId);
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new TSException("根据角色查询资源信息失败\r\n" + e.getMessage());
		}
	}

}
